<%@ page import="java.util.HashMap,common.CommonUtil,java.util.*,common.*" contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/WEB-INF/commontags.tld" prefix="common" %><%--페이징처리tag--%>
<%
UserSession userSession = (UserSession)session.getAttribute("user"); 

String login_id = null;
String user_id = null;
String level = null;

if(userSession!= null){
	login_id = userSession.getLogin_id();
	user_id = userSession.getUser_id();
	level = userSession.getAdmin_level();
}

String start_date	= CommonUtil.nvl(request.getParameter("start_date"),""); 
String end_date	= CommonUtil.nvl(request.getParameter("end_date"),"");

HashMap listMap=(HashMap)request.getAttribute("list_map");

HashMap map  = null;
ArrayList list=null;

HashMap map_1  = null;
ArrayList list_1=null;

String reg_dt 	= "";
String reg_cnt 		= "";
String per_cnt	= "";

String s_total_cnt	= "0";
String s_give_before_cnt	= "0";
String s_progress_cnt	= "0";
String s_end_cnt	= "0";
String s_holding_cnt	= "0";
String v_start_date	= ""; 
String v_end_date	= "";

if (listMap!=null){
    list=(ArrayList)listMap.get("mainContent");
    list_1=(ArrayList)listMap.get("mainContent_1");
}

if(list != null){
	if(list.size() > 0){
		s_give_before_cnt = CommonUtil.nvl((String)((HashMap)list.get(0)).get("s_give_before_cnt"),"0");
		s_progress_cnt = CommonUtil.nvl((String)((HashMap)list.get(0)).get("s_progress_cnt"),"0");
		s_end_cnt = CommonUtil.nvl((String)((HashMap)list.get(0)).get("s_end_cnt"),"0");
		s_holding_cnt = CommonUtil.nvl((String)((HashMap)list.get(0)).get("s_holding_cnt"),"0");
		v_start_date = CommonUtil.nvl((String)((HashMap)list.get(0)).get("v_start_date"),"");
		v_end_date = CommonUtil.nvl((String)((HashMap)list.get(0)).get("v_end_date"),"");
	}
}

if(list_1 != null){
	if(list_1.size() > 0){
		s_total_cnt = CommonUtil.nvl((String)((HashMap)list_1.get(0)).get("s_total_cnt"),"0");
	}
}

if(start_date.equals("")){
	start_date = v_start_date;
}

if(end_date.equals("")){
	end_date = v_end_date;
}

String[] start_date_arr = start_date.split("-");
String[] end_date_arr = end_date.split("-");
%>
<jsp:include page="/jsp/common/header.jsp"></jsp:include>
<script language='javascript' src="/js/calendar.js"></script>
<script>


//검색
function go_search(){
	var frm = document.mainform;
	
	var start_date_arr = frm.start_date.value.split('-');
	var s_year = start_date_arr[0];
	var s_month = Lpad(start_date_arr[1], 2);
	var s_day = Lpad(start_date_arr[2], 2);
	
	frm.start_date.value = s_year+'-'+s_month+'-'+s_day;
	
	var end_date_arr = frm.end_date.value.split('-');
	var e_year = end_date_arr[0];
	var e_month = Lpad(end_date_arr[1], 2);
	var e_day = Lpad(end_date_arr[2], 2);
	
	frm.end_date.value = e_year+'-'+e_month+'-'+e_day;
	
	frm.cmd.value='statistics_opic';
	frm.action = "/speaking.pb";
	frm.target="_self";
	frm.submit();
}

function go_excel(){
	var frm = document.mainform;	
	frm.action = '/jsp/sp_sp0501_opic_excel.jsp';
	frm.target= 'hidden_frm';              
	frm.submit();	
}

</script>
<jsp:include page="/jsp/common/top.jsp"></jsp:include>
<jsp:include page="/jsp/common/submenu.jsp"><jsp:param name="submenu_id" value="statistics_opic" /><jsp:param name="submenu_idx" value="4" /></jsp:include>

<form name="mainform"  method="post" action = "/speaking.pb" >
	<div id="bodyContainer">
        <div id="contents">
          <div class="statistics">
            <table>
              <tr>
                <td>전체 시험완료 횟수</td>
                <td>rater 할당 전 횟수</td>
                <td>rating holding 횟수</td>
                <td>rating 진행 중 횟수</td>
                <td>rating 완료된  횟수</td>
              </tr>
              <tr>
                <td class="frq"><%=s_total_cnt %></td>
                <td class="frq"><%=s_give_before_cnt %></td>
                <td class="frq"><%=s_holding_cnt %></td>
                <td class="frq"><%=s_progress_cnt %></td>
                <td class="frq"><%=s_end_cnt %></td>
              </tr>
            </table>
          </div>
          
          
          <div class="select_menu3">
            <ul>
              <li>시작일 : <INPUT TYPE="text" NAME="start_date"  id="start_date" value="<%=start_date %>" OnFocus=cal(<%=start_date_arr[0] %>,<%=start_date_arr[1] %>,<%=start_date_arr[2] %>,this);></li>
              
              <li class="mt5">~</li>
              <li>종료일 : <INPUT TYPE="text" NAME="end_date"  id="end_date" value="<%=end_date %>" OnFocus=cal(<%=end_date_arr[0] %>,<%=end_date_arr[1] %>,<%=end_date_arr[2] %>,this);></li>
              <li><a href="#" onclick="go_search()"><img src="img/btn_search.gif" alt="search" /></a></li>
              <li><a href="#" onclick="go_excel()"><img src="img/btn_excel.gif" alt="excel" /></a></li>
            </ul>
          </div>
          
          <div class="boxContainer">
            <table class="graphTb">
              <tr>
                <th width="120">일자</th>
                <th width="750">그래프</th>
                <th>시험완료 횟수</th>
              </tr>
<%               

    if (list_1!=null && list_1.size()> 0) {
    	for(int i=0; i<list_1.size(); i++){
	      map=(HashMap)list_1.get(i);
	      reg_dt = CommonUtil.nvl((String)map.get("reg_dt"));
	      reg_cnt = CommonUtil.nvl((String)map.get("reg_cnt"));
	      per_cnt = CommonUtil.nvl((String)map.get("per_cnt"));
%>
			  <tr>
                <td><%=reg_dt %></td>
                <td class="bar"><img src="img/bg_bar02.gif" alt="그래프바" width="<%=per_cnt%>%" height="10" /><br />
                  <%=per_cnt%>%</td>
                <td><%=reg_cnt %></td>
              </tr>
<%	      
    	}
    }else{
%>
              <tr>
                <td colspan=4 align=center>시험완료된 자료가 없습니다.</td>
              </tr>
<%} %>              
              
            </table>            
          </div>
          
        </div>
      </div>


<input type="hidden" name="cmd" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">

</form>

<iframe name='hidden_frm'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
<jsp:include page="/jsp/common/footer.jsp"></jsp:include>
<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
